home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / STRING < prev    next >
Text File  |  1993-05-04  |  1KB  |  38 lines

  1. //
  2. // Session String Routines, By Eric Tauck
  3. //
  4.  
  5. String_End JUMP
  6.  
  7. // ---------------------------------------
  8. // Call a routine for each string element.
  9. // ---------------------------------------
  10.  
  11. : ForString                     // (string routine - )
  12.   SWAP                          // put string address on top
  13.   : ForString1
  14.   DUP @ $FF AND                 // get string element and mask character
  15.   ?DUP ForString2 ?JUMP         // jump if not end of string
  16.     DROP DROP ;                 // fix stack and exit
  17.   : ForString2
  18.   2 PICK CALL BREAK 1+          // call routine, break, and increment string
  19.   ForString1 JUMP               // break and loop back
  20.  
  21. // ---------------------------------------------------
  22. // Call a conditional routine for each string element.
  23. // ---------------------------------------------------
  24.  
  25. : ForString?                    // (string routine - 0 | -1)
  26.   SWAP                          // put string address on top
  27.   : ForString?1
  28.   DUP @ $FF AND                 // get string element and mask character
  29.   ?DUP ForString?2 ?JUMP        // skip exit if not end of string
  30.     DROP DROP TRUE ;            // fix stack and exit
  31.   : ForString?2
  32.   2 PICK CALL BREAK             // call routine and break
  33.   SWAP 1+ SWAP                  // increment string
  34.   ForString?1 ?JUMP             // loop back if success
  35.   DROP DROP FALSE ;             // fix stack and exit
  36.  
  37. : String_End
  38.